package edu.whu.assignment8.util;

import edu.whu.assignment8.dataobject.ReturnObj;
import edu.whu.assignment8.enums.ReturnEnums;

public class ReturnUtil {

    public static ReturnObj success(Object object, String message) {
        ReturnObj returnObj = new ReturnObj();
        returnObj.setStatus(200);
        returnObj.setMessage(message);
        returnObj.setData(object);
        return returnObj;
    }

    public static ReturnObj success(Object object) {
        return success(object,"成功");
    }

    public static ReturnObj success() {
        return success(null);
    }

    public static ReturnObj error(int status, String message) {
        ReturnObj returnObj = new ReturnObj();
        returnObj.setStatus(status);
        returnObj.setMessage(message);
        return returnObj;
    }

    public static ReturnObj error(ReturnEnums returnEnums) {
        return error(returnEnums.getStatus(), returnEnums.getMessage());
    }
}
